package com.itboye.hutouben.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.hutouben.bean.BankCodeBean;
import com.itboye.hutouben.bean.GoPayBean;
import com.itboye.hutouben.bean.JiaoYiJiLuBean;
import com.itboye.hutouben.bean.RepairBean;
import com.itboye.hutouben.bean.SystemMessgeBean;
import com.itboye.hutouben.interfaces.ISystemMeesgeface;
import com.itboye.hutouben.volley.BaseErrorListener;
import com.itboye.hutouben.volley.BaseNetRepository;
import com.itboye.hutouben.volley.BaseSuccessReqListener;
import com.itboye.hutouben.volley.ByJsonRequest;
import com.itboye.hutouben.volley.ICompleteListener;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by itboye on 2016/12/3.
 */

public class SysTemMessgeprinsitory extends BaseNetRepository implements ISystemMeesgeface<SystemMessgeBean> {

    public static final String SystemMeesge = "By_Message_query";//系统消息
    public static final String deleteMeesge = "By_Message_clear";//消息清空

    public static final String Repair_current = "By_Repair_current";//维修（进行中）
    public static final String Delete = "By_Repair_del";//道路九原订单
    public static  final  String ZhanghaoList="By_Wallet_bindList";//支持账号账号列表
    public static  final  String BandingType="By_Wallet_bindType";//支持账号类型
    public static final String Bhang = "By_Wallet_bind";//道路救援
    public static final String zhifu = "By_Repair_pay";//维修支付
    public static final String dingdan = "By_Wallet_his";//余额变动记录   我的订单
    public static final String WanChng = "By_Repair_done";//余额变动记录   我的订单


    public SysTemMessgeprinsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }


    @Override
    public void onSysTemMessge(String uid, String msgtype, String pageindex, String pagesize) {
        Type type = new TypeToken<SystemMessgeBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type", msgtype);
        map.put("page_index", pageindex);
        map.put("page_size", pagesize);

        (new ByJsonRequest.Builder<SystemMessgeBean>())
                .setTypeVerParamsAndReturnClass(SystemMeesge,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<SystemMessgeBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void deleteMess(String uid, String msg_type,String msg_id) {
        Type type = new TypeToken<String>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type", msg_type);
        map.put("msg_id", msg_id);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(deleteMeesge,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
    @Override
    public void deleteMessOne(String uid, String msg_type,String msg_id) {
        Type type = new TypeToken<String>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("msg_type", msg_type);
        map.put("msg_id", msg_id);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(deleteMeesge,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
    @Override
    public void onByRepairCurrent(String uid, String group_id) {
        Type type = new TypeToken<RepairBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("group_id", "6");

        (new ByJsonRequest.Builder<RepairBean>())
                .setTypeVerParamsAndReturnClass(Repair_current,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<RepairBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onDelete(String uid, String id) {
        Type type = new TypeToken<String>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Delete,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onZhangHaoList(String uid) {
        Type Type = new TypeToken<List<BankCodeBean>>() {
        }.getType();
//        String apiVer = API;
        Map<String, Object> map = new HashMap<>();
        map.put("uid",uid);

        (new ByJsonRequest.Builder<List<BankCodeBean>>())
                .setTypeVerParamsAndReturnClass(ZhanghaoList, "100", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<BankCodeBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();


    }

    @Override
    public void onBangDinType() {
        Type Type = new TypeToken<List<BankCodeBean>>() {
        }.getType();
        Map<String, Object> map = new HashMap<>();


        (new ByJsonRequest.Builder<List<BankCodeBean>>())
                .setTypeVerParamsAndReturnClass(BandingType, "100", map, Type)
                .requestListener(
                        new BaseSuccessReqListener<List<BankCodeBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onByWalletBind(String uid, String account, String account_type,String open_bank,String real_name) {
        Type type = new TypeToken<String>() {
        }.getType();
    //    String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("account", account);
        map.put("account_type", account_type);
        map.put("open_bank", open_bank);
        map.put("real_name", real_name);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(Bhang,"101", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    /**
     * 维修支付
     * @param uid
     * @param id
     */
    @Override
    public void onZhiFu(String uid, String id,String score,String bill_type,String bill_title,String bill_code,String address_id) {
        Type type = new TypeToken<GoPayBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        map.put("score", score);
        map.put("bill_type", bill_type);
        map.put("bill_title", bill_title);
        map.put("bill_code", bill_code);
        map.put("address_id", address_id);
        (new ByJsonRequest.Builder<GoPayBean>())
                .setTypeVerParamsAndReturnClass(zhifu,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onZhiFuTwo(String uid, String id, String score,String bill_type,String bill_title,String bill_code,String address_id) {
        Type type = new TypeToken<GoPayBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        map.put("score", score);
        map.put("bill_type", bill_type);
        map.put("bill_title", bill_title);
        map.put("bill_code", bill_code);
        map.put("address_id", address_id);
        (new ByJsonRequest.Builder<GoPayBean>())
                .setTypeVerParamsAndReturnClass(zhifu,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<GoPayBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }


    /**
     * 我的账单
     * @param uid
     * @param current_page
     * @param per_page
     */
    @Override
    public void onZhangDan(String uid, String current_page, String per_page) {
        Type type = new TypeToken<JiaoYiJiLuBean>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("current_page", current_page);
        map.put("per_page", per_page);

        (new ByJsonRequest.Builder<JiaoYiJiLuBean>())
                .setTypeVerParamsAndReturnClass(dingdan,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<JiaoYiJiLuBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }

    @Override
    public void onWieXiuWanchng(String uid, String id, String group_id) {
        Type type = new TypeToken<String>() {
        }.getType();
//        String apiVer = api;
        Map<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("id", id);
        map.put("group_id",group_id);

        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(WanChng,"100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
